$('body').on('click', '#resolveBt', function() {
	$deferred.resolve('1');
	$deferred.done(function(value) {
		console.log('Attache done event after this deferred object has been resoled! ' + value);
	});
	$deferred.always(function(value) {
		console.log('Attache always event after this deferred object has been resoled! ' + value);
	});
	$deferred.fail(function(value) {
		console.log('Attache fail event after this deferred object has been resoled! ' + value);
	});
});
$('body').on('click', '#rejectBt', function() {
	$deferred.reject('2');
	$deferred.done(function(value) {
		console.log('Attache done event after this deferred object has been rejected! ' + value);
	});
});

var $deferred = $.Deferred();
$deferred.done(function(value) {
	console.log("done: " + value);
});
$deferred.fail(function(value) {
	console.log("fail:" + value);
});
$deferred.always(function(value) {
	console.log("Always: " + value);
});

var $filtered = $deferred.pipe(function(value) {
	return value * 2;
});
$filtered.done(function(value) {
	console.log('value in filtered: ' + value);
});

var defer = $.Deferred(),
  filtered = defer.pipe(function( value ) {
    return value * 2;
  });
 
defer.resolve( 5 );
defer.done(function(value) {
	alert('value in defer.done is: ' + value);
});
filtered.done(function( value ) {
  alert( "Value is ( 2*5 = ) 10: " + value );
});
